package flown.window.graphics.widget;

import flown.window.graphics.Scene;

import java.util.ArrayList;


/**
 * @author flown
 */


public class Container
{
    private ArrayList<Widget> widget;

    public Container()
    {
        widget = new ArrayList<Widget>();
    }

    /**
     * 插入到Scene中
     * 需要在Scene的初始化事件中调用
     * @param scene scene
     */
    public final void InsertIntoScene(Scene scene)
    {
        Container that = this;
        scene.AddCommonEvent(renderer -> {

            for (Widget widget : that.widget)
            {
                widget.Render(renderer);
                //if (widget.Intersects())
            }

        });
    }

    public final void AddWidget(Widget widget)
    {
        this.widget.add(widget);
    }
}
